package com.mac.userinfo.login.vo;

import com.mac.userinfo.usermanage.vo.UserInfoVO;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 登陆CAS
 * @author macao
 */
public class UserCAS implements UserDetails {
	private static final long serialVersionUID = 1L;
	/**
	 * 用户ID
	 */
	private String userId;
	/**
	 * 登录ID
	 */
	private String loginId;
	/**
	 * 密码
	 */
	private String password;
	/**
	 * 权限，默认ADMIN
	 */
	private String authorityKind;
	public UserCAS(UserInfoVO users) {
		super();
		this.userId = users.getUserid();
		this.loginId = users.getUserid();
		this.password = users.getUserpwd();
		this.authorityKind = "ADMIN";
	}

	@Override
	public Collection<GrantedAuthority> getAuthorities() {
		List<GrantedAuthority> list = new ArrayList<GrantedAuthority>();
		list.add(new SimpleGrantedAuthority(authorityKind));
		return list;
	}

	@Override
	public String getPassword() {
		return password;
	}

	@Override
	public String getUsername() {
		return loginId;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

}